#include "curva.h"

curva::curva(QWidget *parent) :
    QWidget(parent)
{
//    this->p0 = p0;
//    this->p1 = p1;
//    this->p2 = p2;
}

curva::desenharCurva(QPainter painter, QPointF p0, QPointF p1, QPointF p2){
    QPointF ant1 = p0;
    QPointF ant2 = p1;
    QPointF ant3 = p0;

    for (float t = 0.01; t < 1.001; t+= 0.01)
    {
        QPointF temp1 = (1-t)*p0 + t*p1;
        QPointF temp2 = (1-t)*p1 + t*p2;
        QPointF temp3 = (1-t)*temp1 + t*temp2;

        painter.drawLine(ant3, temp3);

        ant1 = temp1;
        ant2 = temp2;
        ant3 = temp3;
    }
}
